/* Copyright (c) 2013, Shawn McGregor and Steve Mitchell All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. AS3935.h Notes: */ #include #include #ifndef AS3935_H #define AS3935_H // Chipset Configuration Settings #define AS3935_PKGVAL 0x09 // Default Package Value from Manufacturer #define AS3935_Read 0b00000111 // Default Base Address Location Mode Read #define AS3935_Write 0x00000110 // Default Base Address Location Mode Write // Register Locations #define AFE_GB 0x00 // AFE Gain Boost Location #define PWD 0x00 // Power Down #define NF_LEV 0x01 // Noise Floor Level #define WDTH 0x01 // Watchdog Threshold #define CL_STAT 0x02 // Clear Statistics #define MIN_LIGHTNING 0x02 // Min Number of Lightning #define SREJ 0x02 // Spike Rejection #define LCO_FDIV 0x03 // Freq Division Tuning #define DISTURBER 0x03 // Mask Disturber #define INT 0x03 // Interrupt #define DISTANCE 0x07 // Distance Estimation #define DISP_LCO 0x08 // Display LCO on Int Pin #define DISP_SRCO 0x08 // Display SRCO on Int pin #define DISP_TRCO 0x08 // Display TRCO on Int pin #define TUN_CAP 0x08 // Internal tunning cap // Register Masks #define MSK_AFE_GB 0x3E // AFE Gain Boost Location #define MSK_PWD 0x01 // Power Down #define MSK_NF_LEV 0x70 // Noise Floor Level #define MSK_WDTH 0x0F // Watchdog Threshold #define MSK_CL_STAT 0x40 // Clear Statistics #define MSK_MIN_LIGHTNING 0x30 // Min Number of Lightning #define MSK_SREJ 0x0F // Spike Rejection #define MSK_LCO_FDIV 0xC0 // Freq Division Tuning #define MSK_DISTURBER 0x10 // Mask Disturber #define MSK_INT 0x0F // Interrupt #define MSK_DISTANCE 0x3F // Distance Estimation #define MSK_DISP_LCO 0x80 // Display LCO on Int Pin #define MSK_DISP_SRCO 0x40 // Display SRCO on Int pin #define MSK_DISP_TRCO 0x20 // Display TRCO on Int pin #define MSK_TUN_CAP 0x0F // Internal tunning cap #define AFE_INDOOR 0x24 // Settings Mode #define AFE_OUTDOOR 0x1C // Settings Mode #define LIGHTNING_CNT16 0x30 // Lightning must strike 16 times in TIME LIMIT #define LIGHTNING_CNT9 0x20 // strike 9 #define LIGHTNING_CNT5 0x10 // strike 5 #define LIGHTNING_CNT1 0x00 // strike 1 #define INT_NF_LEV_HIGH 0x00 // Detected Noise #define INT_DISTURBER 0x04 // Detected Disturber #define INT_LIGHTNING 0x08 // Detected Lightning #define PWD_ENABLED 0x01 // Power Down Enabled #define PWD_DISABLED 0x00 // Power Down Disabled #define DIST_ENABLED 0x10 // Disturber Mask Enabled #define DIST_DISABLED 0x00 // Disturber Mask Disabled // Code Interface char AS3935i2cRead (char regset); char AS3935i2cWrite (char regset, char value); void AS3935Reset (void); char Calibrate (char tunevalue); char PowerDownEnable (void); char PowerDownDisable (void); char DisturberEnable (void); char LightningMinGet (void); char LightningMinSet (char setting); char LightningDistGetKm (void); char UnitLocationSet (char setting); char NoiseFloorGet (void); char NoiseFloorSet (char setting); char SpikeRejectionGet (void); char SpikeRejectionSet (char setting); char WatchDogThresholdGet (void); char WatchDogThresholdSet (char setting); char ClrStats (void); #endif